package org.jeecg.modules.gongqiang.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.gongqiang.entity.Userhome;
import org.jeecg.modules.gongqiang.mapper.UserhomeMapper;
import org.jeecg.modules.gongqiang.service.IUserhomeService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 用户表
 * @Author: jeecg-boot
 * @Date:   2024-06-11
 * @Version: V1.0
 */
@Service
public class UserhomeServiceImpl extends ServiceImpl<UserhomeMapper, Userhome> implements IUserhomeService {

    @Override
    public Result<?> checkUserIsEffective(Userhome userhome) {
        Result<?> result = new Result<Object>();
        //情况1：根据用户信息查询，该用户不存在
        if (userhome == null) {
            result.error500("该用户不存在，请注册");
            return result;
        }
        //情况3：根据用户信息查询，该用户已冻结
        if (userhome.getStatus().equals(0)) {
            result.error500("该用户已冻结");
            return result;
        }
        return result;
    }

    @Override
    public void setAccessToken(Integer id, String token) {
        this.baseMapper.setAccessToken(id, token);
    }

    @Override
    public IPage<Userhome> pageList(Page<Userhome> page, QueryWrapper<Userhome> queryWrapper) {
        return this.baseMapper.getPageList(page, queryWrapper);
    }

    @Override
    public Userhome getByUsername(String username)
    {
        return this.baseMapper.getByUsername(username);
    }

}
